<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "./mixins/resize";
import { getBusinessOpportunities } from "@/api/admin_jsc";
const animationDuration = 3000;
const emphasisStyle = {
  itemStyle: {
    barBorderWidth: 1,
    shadowBlur: 10,
    shadowOffsetX: 0,
    shadowOffsetY: 0,
    shadowColor: "rgba(0,0,0,0.5)",
  },
};
export default {
  mixins: [resize],
  props: {
     listQuery: {
      type: Object,
    },
    className: {
      type: String,
      default: "chart",
    },
    width: {
      type: String,
      default: "100%",
    },
    height: {
      type: String,
      default: "350px",
    },
    autoResize: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      showbtns: false,
      chart: null,
       xData: [],
      yData: [],
      yData1: [],
      yData2: [],
      yData3: [],

    };
  },

  mounted() {
      this.getList();
    
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
 methods: {
    getList() {
      
      getBusinessOpportunities(this.listQuery).then((res) => {
        
        this.$nextTick(() => {
          this.initChart();
        });
      });
    },
    initChart() {
      this.chart = echarts.init(this.$el, "macarons");
      this.chart.setOption({
        color: ["#FF89B0", "#FFCF5A", "#6EF3ED", "#AB84FF", "#52A8FE"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            crossStyle: {
              color: "#999",
            },
          },
        },
        toolbox: {
          
        },
        legend: {
          left: "60",
          data: [
            "高校邦运营服务",
            "精品在线开放课程产品",
            "课程拍摄于制作服务",
            "高校邦学习平台",
            "平均",
          ],
        },
        xAxis: [
          {
             type: "category",
             axisTick:{
              show:false
            },
            splitLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            data: this.xData,
            axisPointer: {
              type: "shadow",
            },
            axisLine: {
              lineStyle: {
                color: "#616266",
              },
            }, 
          },
        ],
          yAxis: [
          {
            type: "value",
             axisLine: {
                show:false,
              lineStyle: {
                color: "#616266",
              },
            },
            axisTick: {
              show: false,
            },
            name: "",
             nameTextStyle:{
          color: "#616266",
               },
            min: 0,
            // max: 2500,
            axisTick: {
              show: false,
            },
            splitLine: {
              show: false,
            },
            axisLabel: {
              formatter: "{value}",
              textStyle: {
                color: "#616266",
              },
            },
          },
          {
            type: "value",
            name: "",
             nameTextStyle:{
          color: "#616266",
               },
            min: 0,
            max: 25,
            interval: 5,
            axisTick: {
              show: false,
            },
            axisLabel: {
              formatter: "{value}",
              textStyle: {
                color: "#616266",
              },
            },
          },
        ],
        series: [
          {
            emphasis: emphasisStyle,
            name: "高校邦运营服务",
            type: "bar",
            barCategoryGap:'50%',
            data:this.yData,
          },
          {
            name: "精品在线开放课程产品",
            type: "bar",
            data: this.yData3,
          },
          {
            name: "平均",
            type: "line",
           
            data: this.yData2,
          },
          {
            name: "课程拍摄于制作服务",
            type: "bar",

            data:this.yData1,
          },
          {
            name: "高校邦学习平台",
            type: "bar",

            data:this.yData,
          },
        ],
      });
    },
  },
};
</script>
